package day08.thread;

/**
 * @Auther: sky
 * @Date: 2019/3/2 22:28
 * @Description:
 */
public class LoginServlet {
    private  String userNameRed;
    private  String passwordRed;

    public String getUserNameRed() {
        return userNameRed;
    }

    public void setUserNameRed(String userNameRed) {
        this.userNameRed = userNameRed;
    }

    public String getPasswordRed() {
        return passwordRed;
    }

    public void setPasswordRed(String passwordRed) {
        this.passwordRed = passwordRed;
    }

    private static LoginServlet loginServlet;

    private LoginServlet() {
    }

    ;

    synchronized public static LoginServlet getLoginServlet() {
        if (null == loginServlet) {
            loginServlet = new LoginServlet();
        }
        return loginServlet;
    }

    synchronized public void doPost(String userName, String password) {
        try {
            userNameRed = userName;
//            if (userName.equals("b")) {
//                Thread.sleep(5000);
//            }
            passwordRed = password;
            System.out.println("userName=" + userNameRed + ",password=" + passwordRed);


        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
